package cn.mabach.portal.controller;

import cn.mabach.DTO.RS;
import cn.mabach.business.entity.AdEntity;
import cn.mabach.portal.feign.AdServiceFeign;
import cn.mabach.portal.feign.CategoryServiceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
public class IndexController {
    @Autowired
    private AdServiceFeign adServiceFeign;
    @Autowired
    private CategoryServiceFeign categoryServiceFeign;

    @RequestMapping({"","/","/index"})
    public String index(Model model){
        RS<List<AdEntity>> web_index_lb = adServiceFeign.findByPosition("web_index_lb");
        RS<List<Map>> categoryTree = categoryServiceFeign.findCategoryTree();
        model.addAttribute("lbt",web_index_lb.getData());
        model.addAttribute("categoryTree",categoryTree.getData());
        return "index";
    }
}
